import { skuDataResponseData, SkuInfoData } from "@/types/sku";
import http from "@/utils/request";

enum API {
    //获取已有的商品的数据-SKU
    SKU_URL = '/admin/product/list/',
    //上架
    SALE_URL = '/admin/product/onSale/',
    //下架的接口
    CANCELSALE_URL = '/admin/product/cancelSale/',
    //获取商品详情的接口
    SKUINFO_URL = '/admin/product/getSkuInfo/',
    //删除已有的商品
    DELETESKU_URL = '/admin/product/deleteSku/'
}

//获取已有商品的数据
export const getProductListAPI=(page:number,limit:number)=>{
    return http<any,skuDataResponseData>({
        url:API.SKU_URL+`${page}/${limit}`
    })
}
//已有商品上架的请求
export const reqSaleSku = (skuId: number) => http.get<any, any>(API.SALE_URL + skuId);
//下架的请求
export const reqCancelSale = (skuId: number) => http.get<any, any>(API.CANCELSALE_URL + skuId);
//获取商品详情的接口
export const reqSkuInfo = (skuId: number) => http.get<any, SkuInfoData>(API.SKUINFO_URL + skuId);
//删除某一个已有的商品
export const reqRemoveSku = (skuId: number) => http.delete<any, any>(API.DELETESKU_URL + skuId)